package com.pyk.mapper;


import com.pyk.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    @Select("select * from users where #{username}=username")
    User findByUsername(String username);

    @Insert("insert into users(username,password,create_time,update_time)" +
            " values(#{username},#{password},now(),now())")
    void add(String username, String password);

    @Update("update users set email=#{email},name=#{name},phone=#{phone},update_time=now()  where user_id=#{userId}")
    void update(User user);

    @Update("update users set user_pic=#{avatarUrl} ,update_time=now() where user_id=#{id}")
    void updateAvatar(String avatarUrl ,Integer id);

    @Update("update users set password=#{newPwd} where user_id=#{userId}")
    void updatePwd(String newPwd, Integer userId);
}
